﻿@model TemplateContext<Paragraph>

@{
	Paragraph contextObject = Model.Object;
	
	var parentTextFrame = Model.Local.Get<TextFrame>("parent");
    var tableContentFlag = Model.Local.Get<bool>("tableContent");
	var parentContainerSize = Model.Local.Get<SizeF>("parentContainerSize");
	
	var paragraphFormatEffective = contextObject.ParagraphFormat.GetEffective();
	
	double[] margins = TextHelper.GetParagraphMargins(paragraphFormatEffective, parentTextFrame, parentContainerSize, Model);
}

@functions
{
    string GetTextStyle(Paragraph paragraph)
    {
        return TextHelper.GetTextStyle(paragraph.ParagraphFormat.GetEffective(), Model);
    }
}

<p style="margin-left: @margins[0]px; margin-top: @margins[1]px; margin-right: @margins[2]px; margin-bottom: @margins[3]px; @GetTextStyle(contextObject)">
	@if (paragraphFormatEffective.Bullet.Type != BulletType.None)
	{
		@Raw(Include("bullet", Model).ToString().Replace(Environment.NewLine, ""))
	}
	@foreach (Portion portion in contextObject.Portions) 
	{ 
        var subModel = Model.SubModel(portion);
        subModel.Local.Put("parentTextFrame", parentTextFrame);
        subModel.Local.Put("tableContent", tableContentFlag);
		@Raw(Include("portion", subModel).ToString().Replace(Environment.NewLine, ""));
	}
</p>